package com.hx.myfristandriod;
import com.hx.thread.CalculateThread;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

public class TestActivity extends Activity {
    
	    private EditText txtName;
	    private Button btnSend;
	    private Button btnFile;
	    private Button btnListView;
	    private Button btnSqlite;
	    private Button btnHeightListView;
	    private Button btnTabHost;
	    private Button btnCalculate;
	    public static  String CalResult;

		@Override
		protected void onCreate(Bundle savedInstanceState) {
	        super.onCreate(savedInstanceState);
	        setContentView(R.layout.activity_test);
	        txtName=(EditText) findViewById(R.id.txtName);
	        //信息获取
	        btnSend=(Button) findViewById(R.id.btnSend);
	        btnSend.setOnClickListener(new ViewOcl());
	        //listview显示
	        btnListView=(Button) findViewById(R.id.btnListView);
	        btnListView.setOnClickListener(new ViewOcl());
	        //file读取
	        btnFile=(Button) findViewById(R.id.btnFile);
	        btnFile.setOnClickListener(new ViewOcl());
	        
	        //sqlite操作
	        btnSqlite=(Button) findViewById(R.id.btnSqlite);
	        btnSqlite.setOnClickListener(new ViewOcl());
	        //btnHeightListView操作
	        btnHeightListView=(Button) findViewById(R.id.btnHeightListView);
	        btnHeightListView.setOnClickListener(new ViewOcl());
	        
	        //btnHeightListView操作
	        btnTabHost=(Button) findViewById(R.id.btnTabHost);
	        btnTabHost.setOnClickListener(new ViewOcl());
	        
	        //调用webservice服务中的计算器"
	        btnCalculate=(Button) findViewById(R.id.btnCalculate);
	        btnCalculate.setOnClickListener(new ViewOcl());
	    }

	    //btn绑定监听事件，发送信息单击调用
  class ViewOcl implements OnClickListener{
	@Override
	public void onClick(View v) {
		  Intent intent=new Intent();
      switch (v.getId()) {
	       case R.id.btnSend:
			  intent.setClass(TestActivity.this,TestAlertActivity.class);
			  String name=txtName.getText().toString().trim();
			  intent.putExtra("txtName", name);
			 startActivity(intent);
			 break;
	       case R.id.btnListView:
				  intent.setClass(TestActivity.this,TestListViewActivity.class);
				 startActivity(intent);
				 break;
	       case R.id.btnFile:
				  intent.setClass(TestActivity.this,TestFileActivity.class);
				 startActivity(intent);
				 break;
	       case R.id.btnSqlite:
				  intent.setClass(TestActivity.this,TestSqliteActivity.class);
				 startActivity(intent);
				 break;
	    case R.id.btnHeightListView:
			  intent.setClass(TestActivity.this,TestHieghtListViewActivity.class);
			 startActivity(intent);
			 break;
	    case R.id.btnTabHost:
			  intent.setClass(TestActivity.this,TestTabHostActivity.class);
			 startActivity(intent);
			 break;
	    case R.id.btnCalculate:
			    CalculateThread cal=new CalculateThread();
			    cal.start();
			    txtName.setText(CalResult);
			 break;
    	default:
			break;
         	}
	}
	} 
}
